home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Modules / BackSpaceModules / Source / Polyhedra / PolyhedraView.h < prev    next >
Text File  |  1992-04-16  |  2KB  |  98 lines

  1. //
  2. // RegularPolyhedraView  -  a flexible, bouncing polyhedron.
  3. //
  4. // Module for BackSpace.app
  5. // 22 Nov 91 - 8 Dec 91.
  6. // Simon Marchant, and Paul Brown (simon@math.berkeley.edu,
  7. //        pbrown@math.berkeley.edu).
  8. //
  9.  
  10.  
  11. #import <appkit/View.h>
  12. #import "Thinker.h"
  13. #import "BackView.h"
  14.  
  15. //#define SPRING_K            0.2
  16. #define SPRING_K            0.15
  17. #define SPRING_REST_LEN        150
  18.  
  19. // #define DAMPING                0.1
  20. #define DAMPING                0.05
  21.  
  22. #define DEPTH                2
  23. //#define MASS                10
  24. #define MASS                15
  25.  
  26. #define TETRAHEDRON            0
  27. #define CUBE                1
  28. #define OCTAHEDRON            2
  29. #define DODECAHEDRON        3
  30. #define ICOSAHEDRON            4
  31.  
  32. #define NUM_POLYHEDRA        (ICOSAHEDRON + 1)
  33.  
  34. #define MAX_NUM_VERTICES        20
  35. #define    MAX_NUM_ADJACENTS        5
  36. #define MAX_NUM_FACES            20
  37. #define MAX_VERTICES_PER_FACE    5
  38.  
  39. // #define INIT_VELOCITY        10
  40. #define INIT_VELOCITY        10
  41. //#define MAX_VEL                100
  42. #define MAX_VEL                100
  43.  
  44. typedef struct
  45.     {
  46.     float    x,y,z;
  47.     } D3_PT;
  48.  
  49. typedef struct
  50.     {
  51.     float    mass;
  52.     D3_PT    vel;
  53.     D3_PT    pos;
  54.     NXPoint screenPos;
  55.     } VERTEX;
  56.  
  57. @interface PolyhedraView:View
  58. {
  59.     int            polyhedron;
  60.     int            selectedIndex;
  61.     int            numVertices;
  62.     int            numAdjacents;
  63.     int            numFaces;
  64.     int            numDrawFaces;
  65.     int            verticesPerFace;
  66.     int            realAdjacents;
  67.  
  68.     VERTEX        vertices[MAX_NUM_VERTICES];
  69.     float        restLengths[MAX_NUM_VERTICES][MAX_NUM_VERTICES];
  70.     BOOL        isAdjacent[MAX_NUM_VERTICES][MAX_NUM_VERTICES];
  71.  
  72.     D3_PT        perspectivePt;
  73.     D3_PT        backTopRight;
  74.  
  75.     float        damping;
  76.  
  77.     BOOL        noAnimation;
  78.     int            backStep;
  79.     id            inspectorPanel;
  80. }
  81.  
  82. - oneStep;
  83. - drawSelf:(const NXRect *)rects :(int)rectCount;
  84. - initFrame:(const NXRect *)frameRect;
  85. - useNewFrame:(const NXRect *)frameRect;
  86.  
  87. - perspectiveLineFrom:(D3_PT)pt1 to:(D3_PT)pt2;
  88. - drawBoxInColour:(float)theGray;
  89. - drawPolyhedron;
  90. - erasePolyhedron;
  91. - frameChanged:(const NXRect *)frameRect;
  92.  
  93. - setSelectedIndex:sender;
  94. - kickIt:sender;
  95. - inspector:sender;
  96.  
  97. @end
  98.